<?php
require_once('f.php');
do
{
   $upErr = false;

	if (!isset($_POST['username']) || !isset($_POST['password']))
	{      
      break;
	}   

   $cr = loadCredentials();

   if ($_POST['username'] != $cr['username'] || $_POST['password'] != $cr['password'])
   {
      $upErr = true;
      break;
   }

   session_start();
   $_SESSION["access"] = "granted";
   header("Location: ./main.php");

} while (false);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="index,follow" name="robots" />
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
<link href="pics/homescreen.gif" rel="apple-touch-icon" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/style.css" rel="stylesheet" media="screen" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<title><?php echo getTitle()?></title>
</head>

<body>

<div id="topbar">
	<div id="title">
		<?php echo getTitle()?></div>	
</div>
<div id="content">
   <?php if ($upErr):?>
	<ul class="pageitem">
		<li class="textbox"><span class="header">Ops!</span> Username o password errate.</li>
	</ul>
   <?php endif;?>
	<form method="post" action="index.php">
		
		<span class="graytitle">Credentials</span>
		<ul class="pageitem">
			<li class="smallfield"><span class="name">Username</span><input placeholder="" type="text" id="username" name="username" />
			</li>
			<li class="smallfield"><span class="name">Password</span><input placeholder="" type="password" id="password" name="password" />
			</li>
		</ul>		
		<ul class="pageitem">
			<li class="checkbox"><span class="name">Remember Me </span>
			<input name="remember" type="checkbox" /> </li>			
	     <li class="button">
			<input name="Submit input" type="submit" value="Log me in!" /></li>
		</ul>						
		</fieldset></form>
</div>
<div id="footer">
	<a href="http://iwebkit.net">Powered by iWebKit</a></div>

</body>

</html>
